package qc.module.ehs.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.ehs.dto.investrecord.InvestRecordDto;
import qc.module.ehs.entity.EhsInvestRecord;

import java.util.List;

/**
 * EhsInvestRecordMapper
 *
 * @author QuCheng Tech
 * @create 2024/10/29
 */
@Mapper
public interface EhsInvestRecordMapper {
    EhsInvestRecordMapper MAPPER = Mappers.getMapper(EhsInvestRecordMapper.class);

    /**
     * entity -> dto
     * @param en
     * @return
     */
    @Mapping(target = "intm", source = "intm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "begintm", source = "begintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "endtm", source = "endtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    InvestRecordDto toDto(EhsInvestRecord en);

    /**
     * List<entity> -> List<dto>
     * @param ens
     * @return
     */
    List<InvestRecordDto> toDtoList(List<EhsInvestRecord> ens);

    /**
     * dto -> entity
     * @param dto
     * @return
     */
    @Mapping(target = "intm", source = "intm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "begintm", source = "begintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "endtm", source = "endtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    EhsInvestRecord toEntity(InvestRecordDto dto);
}
